// document.cookie="token=82b6f469b4bd613a1b2ee10bb4d0afabbf4d7865"
getCookie=function(name){
    var arr=document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
    if(arr!=null)return unescape(arr[2]); return "";
}
var token= getCookie("token");
function html_decode(str)
{
    var s = "";
    if (str.length == 0) return "";
    s = str;
    s = s.replace(/&amp;/g, "&");
    s = s.replace(/&lt;/g, "<");
    s = s.replace(/lt;/g, "<");
    s = s.replace(/&gt;/g, ">");
    s = s.replace(/gt;/g, ">");
    s = s.replace(/&nbsp;/g, " ");
    s = s.replace(/&#39;/g, "\'");
    s = s.replace(/&quot;/g, "\"");
    s = s.replace(/<br>/g, "\n");
    return s;
}
$(function(){
    //	获取个人资料
    $.ajax({
        url:'http://ww.yc630.com/api/index.php/Buyer/User/userinfo',
        type:"post",
        data:{
            'token':token
        },
        dataType:"JSON",
        success:function(data){
            var avatar = data['data']['avatar'];
            if(avatar==''){
                avatar = '../img/Group%2019.png';
            }
            $("#headPic").attr('src',avatar)
        }
    })
    //获得商家信息
    $.ajax({
        type:"post",
        url:"http://ww.yc630.com/api/index.php/Buyer/Goods/sellerdetail",
        data:{
            'token':token
        },
        dataType:'json',
        success:function(data){
            $("#icon_img").attr('src',data.data.icon_image)
            $("#icon_name").html(data.data.name)
        }
    });
    //获得品牌列表
    $.ajax({
        type:"post",
        url:"http://ww.yc630.com/api/index.php/Seller/Goods/brandist",
        data:{
            'token':token
        },
        dataType:'json',
        success:function(phpdata){
            var str = '';
            for(i in phpdata['data']){

                str += '<option value="'+i+'">'+phpdata['data'][i]+'</option>';
            }
            $('select[name="brand"]').append(str);
        }

    });

    //获得人群风格
    $.ajax({
        type:"post",
        url:"http://ww.yc630.com/api/index.php/Seller/Goods/peopleStylelist",
        data:{
            'token':token
        },
        dataType:'json',
        success:function(phpdata){
            var str = '';
            for(i in phpdata['data']){

                str += '<option value="'+i+'">'+phpdata['data'][i]+'</option>';
            }

            $('select[name="people_style"]').append(str);

        }
    });
    //获得购买属性
    $.ajax({
        type:"post",
        url:"http://ww.yc630.com/api/index.php/Seller/Belong/belong_list",
        data:{
            'token':token
        },
        dataType:'json',
        success:function(phpdata){
            var str = '';
            for(i in phpdata['data']['tpls']){

                str += '<option value="'+phpdata['data']['tpls'][i]['id']+'">'+phpdata['data']['tpls'][i]['tpl_name']+'</option>';
            }

            $('select[name="attr"]').append(str);

        }
    });

    //发货地省
    $.ajax({
        type:"post",
        url:"http://ww.yc630.com/api/index.php/Buyer/User/getProvince",
        data:{
            'token':token
        },
        dataType:'json',
        success:function(phpdata){
            var opt = '';
            $.each(phpdata['data'], function(k,v) {

                opt +='<option value="'+k+'">'+v+'</option>';
            });
            $('select[name="shipaddress_province"]').append(opt);
        }
    });


    //发货地市区
    $('select[name="shipaddress_province"]').change(function(){
        $('select[name="shipaddress_city"]').html('<option value="0">请选择市、区</option>');
        var provinceid = $(this).children(':selected').val();

        $.ajax({
            type:"post",
            data:{'provinceid':provinceid,'token':token},
            url:"http://ww.yc630.com/api/index.php/Buyer/User/getCity",
            dataType:'json',
            success:function(phpdata){
                var opt = '';
                $.each(phpdata['data'], function(k,v) {

                    opt +='<option value="'+k+'">'+v+'</option>';
                });
                $('select[name="shipaddress_city"]').append(opt);
            }
        });
    })
    //获得商品风格
    $('select[name="people_style"]').change(function(){
        var people_style = $(this).val();
        $('select[name="goods_style"]').html('<option value="0">请选择适宜风格</option>');
        if(people_style == 0){
            $('select[name="goods_style"]').html('<option value="0">请选择适宜风格</option>');
            return false;
        }
        $.ajax({
            type:"post",
            url:"http://ww.yc630.com/api/index.php/Seller/Goods/goodsStylelist",
            data:{'people_style':people_style,'token':token},
            dataType:'json',
            success:function(phpdata){
                var str = '';
                for(i in phpdata['data']){

                    str += '<option value="'+i+'">'+phpdata['data'][i]+'</option>';
                }

                $('select[name="goods_style"]').append(str);
            }
        });
    })


    //产地省
    $.ajax({
        type:"post",
        url:"http://ww.yc630.com/api/index.php/Buyer/User/getProvince",
        data:{
            'token':token
        },
        dataType:'json',
        success:function(phpdata){
            var opt = '';
            $.each(phpdata['data'], function(k,v) {

                opt +='<option value="'+k+'">'+v+'</option>';
            });
            $('select[name="prodaddress_province"]').append(opt);
        }
    });


    //产地市区
    $('select[name="prodaddress_province"]').change(function(){
        $('select[name="prodaddress_city"]').html('<option value="0">请选择市、区</option>');
        var provinceid = $(this).children(':selected').val();

        $.ajax({
            type:"post",
            data:{'provinceid':provinceid,'token':token},
            url:"http://ww.yc630.com/api/index.php/Buyer/User/getCity",
            dataType:'json',
            success:function(phpdata){
                var opt = '';
                $.each(phpdata['data'], function(k,v) {

                    opt +='<option value="'+k+'">'+v+'</option>';
                });
                $('select[name="prodaddress_city"]').append(opt);
            }
        });
    })

    //获得运费模板
    $.ajax({
        type:"post",
        url:"http://ww.yc630.com/api/index.php/Seller/Freight/freight_list",
        data:{'token':token},
        dataType:'json',
        success:function(phpdata){
            var str = '';
            for(i in phpdata['data']){

                str += '<option value="'+phpdata['data'][i]['id']+'">'+phpdata['data'][i]['name']+'</option>';
            }

            $('select[name="freight_name"]').append(str);
        }
    });

    //图片上传
    $("#file_upload").uploadify({

        'swf'           : '../uploadify/uploadify.swf',
        'uploader'      : 'http://ww.yc630.com/api/index.php/Seller/Seller/upload',
        'width':58,
        'height':58,
        'multi'         : true,
        'removeTimeout' : 0.2,//成功显示时间
        'fileTypeExts' : '*.jpg;*.png',
        'scriptAccess' : 'always',
        'onUploadSuccess' : function(file, data, response) {
            var img_len = $('.imgs').length
            if(img_len >= 5){

                 alert('最多可上传五张图片');
                 return false;
            }
            data=$.parseJSON(data);
            var str = '<div style="position: relative" class="add_pic_btn imgs"><img class="little_sc"  img_id="'+data['data'][0]['imageid']+'"  src="'+data['data'][0]['image']+'"/><span class="little_sc" onclick="sc(this)">X</span></div>';
            $('.goods_img').prepend(str);

        }
    });

    //属性模板详情
    $('select[name="attr"]').change(function(){
        var id = $(this).val();
        $('.attr_table').html('');

        $.ajax({
            type:"post",
            url:"http://ww.yc630.com/api/index.php/Seller/Belong/belong_detail",
            data:{'id':id,'token':token},
            dataType:'json',
            success:function(phpdata){
                var str = '';
                var price_attr = '';
                for(i in phpdata['data'][id]['attr']){
                    str +='<tr><td class="z_td_w" name="'+phpdata['data'][id]['attr'][i]['attr_name']+'" style="text-align: left;width: 60px;">'+phpdata['data'][id]['attr'][i]['attr_name']+':</td><td>';
                    var attrs = phpdata['data'][id]['attr'][i]['value'].split(',');
                    for(j in attrs){
                        str +='<input class="z_s z_attrs" z_shu="'+phpdata['data'][id]['attr'][i]['attr_name']+'" z_names="'+attrs[j]+'" type="checkbox" name=""  /> <label class="z_label">'+attrs[j]+'</label> ' ;
                    }
                    str +='<a href="###" attr_name="'+phpdata['data'][id]['attr'][i]['attr_name']+'" class="hand_add hand_a" >添加</a></td></tr>';

                    price_attr += '<input class="z_s" type="radio" name="price_attr" id="'+phpdata['data'][id]['attr'][i]['attr_name']+'" /><label class="z_label" for="'+phpdata['data'][id]['attr'][i]['attr_name']+'">按'+phpdata['data'][id]['attr'][i]['attr_name']+'设定</label>';
                }
                $('.price_attr').html(price_attr);
                $('.attr_table').html(str);
                $('.attr_list').html('');
            }
        });

    })

    //属性值复选框发生变化 价格设定 html发生变化
    $('.z_table').on('change','.z_attrs',function(){
        var z_shu = $(this).attr('z_shu');
        var price_attr =  $('input:radio[name="price_attr"]:checked').attr('id');


        var str = '<tr class="z_head"><td>条形码</td><td>'+price_attr+'</td><td>销售价</td><td>原价</td><td>库存</td></tr>';
        if($(this).is(':checked')){

            if(z_shu == price_attr){
                $('input:checkbox[z_shu='+z_shu+']:checked').each(function(i){
                    var z_names = $(this).attr('z_names');
                    str +='<tr class="z_list_main"><td><input style="height: 100%;border: 0;" type="text" name="" id="" /></td><td>'+z_names+'</td><td><input style="height: 100%;border: 0;" type="text" name="" id="" /></td><td><input style="height: 100%;border: 0;" type="text" name="" id="" /></td><td><input style="height: 100%;border: 0;" type="text" name="" id="" /></td></tr>';
                })
                $('.attr_list').html(str);

            }

        }else{

            if(z_shu == price_attr){
                $('input:checkbox[z_shu='+z_shu+']:checked').each(function(i){
                    var z_names = $(this).attr('z_names');
                    str +='<tr class="z_list_main"><td><input style="height: 100%;border: 0;" type="text" name="" id="" /></td><td>'+z_names+'</td><td><input style="height: 100%;border: 0;" type="text" name="" id="" /></td><td><input style="height: 100%;border: 0;" type="text" name="" id="" /></td><td><input style="height: 100%;border: 0;" type="text" name="" id="" /></td></tr>';
                })
                $('.attr_list').html(str);

            }

        }

    })




    //添加属性
    $('.hand_and').click(function(){

        var title_con = '请输入想要添加的属性';
        var price_attr = '';
        layer.prompt({title: title_con, formType: 0}, function(pass, index){
            layer.close(index);
            var str = '<tr><td class="z_td_w" name="'+pass+'" style="text-align: left;width: 60px;">'+pass+':</td><td><a href="###" attr_name="'+pass+'" class="hand_add hand_a" >添加</a></td></tr>';
            price_attr += '<input class="z_s" type="radio" name="price_attr" id="'+pass+'" /><label class="z_label" for="'+pass+'">按'+pass+'设定</label>';
            $('.price_attr').append(price_attr);
            $('.attr_table').append(str);

        });

    })

    //添加属性值
    $('.attr_table').on('click','.hand_a',function(){

        var attr_name = $(this).attr('attr_name');
        var title_con = '请输入想要添加的'+attr_name;
        $this=$(this);
        layer.prompt({title: title_con, formType: 0}, function(pass, index){
            layer.close(index);
            var str = '<input class="z_s z_attrs" z_shu="'+attr_name+'" z_names="'+pass+'" type="checkbox" name=""  /> <label class="z_label">'+pass+'</label>'


            $this.parent('td').prepend(str);

        });
    })

    //价格设定的属性
    $('.price_attr').on('change','input:radio[name="price_attr"]',function(){
        var price_attr =  $('input:radio[name="price_attr"]:checked').attr('id');
        var str = '<tr class="z_head"><td style="width: 100px">条形码</td><td style="width: 100px!important;">'+price_attr+'</td><td>销售价</td><td>原价</td><td>库存</td></tr>';

        $('input:checkbox[z_shu='+price_attr+']:checked').each(function(i){
            var z_names = $(this).attr('z_names');
            str +='<tr class="z_list_main"><td><input style="height: 100%;border: 0;" type="text" name="" id="" /></td><td>'+z_names+'</td><td><input style="height: 100%;border: 0;" type="text" name="" id="" /></td><td><input style="height: 100%;border: 0;" type="text" name="" id="" /></td><td><input style="height: 100%;border: 0;" type="text" name="" id="" /></td></tr>';
        })

        $('.attr_list').html(str);

    })




    $('.save_back').click(function(){
    	
        //    接收id
        var url=window.location.href
        var ids=url.split("?")[1]
        var id=ids.substring(3)
        var form = $(this).closest('form');
        var goods_name = form.find('input[name="goods_name"]').val();
        if(goods_name == ''){
            noticebox('提示','商品名不能为空',1);
            return false;
        }
        var brand = form.find('select[name="brand"]').val();
        if(brand == 0){
            noticebox('提示','品牌名不能为空',1);
            return false;
        }
        //人群风格
        var people_style = form.find('select[name="people_style"]').val();
        if(people_style == 0){
           noticebox('提示','人群风格不能为空',1);
            return false;
        }
        //商品风格
        var goods_style = form.find('select[name="goods_style"]').val();
        if(goods_style == 0){
            noticebox('提示','商品风格不能为空',1);
            return false;
        }


        //货号
        var artnu = form.find('input[name="artnu"]').val();
        if(artnu == ''){
            noticebox('提示','货号不能为空',1);
            return false;
        }
        //产地
        var prodaddress = form.find('select[name="prodaddress_city"]').val();
        if(prodaddress == 0){
            noticebox('提示','产地不能为空',1);
            return false;
        }
        //产地
        var prodprovince_address = form.find('select[name="prodaddress_province"]').val();
        if(prodaddress == 0){
            noticebox('提示','产地不能为空',1);
            return false;
        }
        //发货地
        var shipaddress = form.find('select[name="shipaddress_city"]').val();
        if(shipaddress == 0){
            noticebox('提示','发货地不能为空',1);
            return false;
        }
        //发货地
        var shipprovince_address = form.find('select[name="shipaddress_province"]').val();
        if(shipaddress == 0){
           noticebox('提示','发货地不能为空',1);
            return false;
        }
        //属性*
        // 遍历所有的table数据
        var html='';
        var tr_len = $('.attr_table').find('tr').length;
        $('.attr_table').find('tr').each(function (i) {

            $(this).find('td').each(function () {
                if($(this).attr('class') == 'z_td_w'){
                    html +=$(this).attr('name')+',';
                }else{
                    var len = $(this).find('input:checkbox:checked').length;

                    $(this).find('input:checkbox:checked').each(function(i){
                        if(len == (i+1)){
                            html += $(this).attr('z_names');
                        }else{
                            html += $(this).attr('z_names')+',';
                        }

                    })
                }
            });
            if(tr_len != (i+1)){
                html +=";"
            }

        });

        var attr = html;
        if(attr == ''){
            noticebox('提示','商品属性不能为空',1);
            return false;
        }

        //定价属性*
        var price_attr = form.find('input:radio[name="price_attr"]:checked').attr('id');
        if(price_attr == ''){
            noticebox('提示','定价属性不能为空',1);
            return false;
        }

        //定价属性值**
        var list_len = $('.z_list_main').length;
        var price_attr_value = '';
        $('.z_list_main').each(function(i){

            var td_len = $(this).find('td').length;
            $(this).find('td').each(function(j){
                if(j==1){
                    price_attr_value += $(this).html()+',';
                }else{
                    if($(this).find('input:text').val() == ''){
                        noticebox('提示','请填写完整定价属性值',1);
                        return false;
                    }
                    if(td_len == (j+1)){
                        price_attr_value += $(this).find('input:text').val();
                    }else{
                        price_attr_value += $(this).find('input:text').val()+',';
                    }

                }

            })
            if(list_len != (i+1)){
                price_attr_value +=';'
            }


        })
        if(price_attr_value == ''){
            noticebox('提示','定价属性值不能为空',1);
            return false;
        }


        //库存提醒
        var notice_nu = form.find('input:radio[name="notice_nu"]:checked').val();
        if(notice_nu==1){
            var notice_nu = $('input[name="notice_nu_num"]').val();

        }

        if(notice_nu==''){
            noticebox('提示','库存提醒不能为空',1);
            return false;
        }
        //运费模板*
        var freightmodel = '';
        var freight = ''
        var freight = $('input[name="freight"]:checked').val();

        if(freight == 1){
            var freight_name = $('select[name="freight_name"]').val();
            if(freight_name == 0){
               noticebox('提示','请选择运费模板',1);
                return false;
            }
            var freightmodel = freight_name;
        }else{
            var freightmodel = freight;
        }
        if(freightmodel == ''){
            noticebox('提示','请选择运费',1);
            return false;
        }
        //商品重量
        var weight = form.find('input[name="weight"]').val();
        if(weight == ''){
			noticebox('提示','重量不能为空',1);
            
            return false;
        }

        //图片**
        var image = '';
        var img_len = $('.imgs').length;
        $('.imgs').each(function(i){
            if(img_len == (i+1)){
                image += $(this).find('img').attr('img_id');
            }else{
                image += $(this).find('img').attr('img_id')+',';
            }

        })
        if(image == ''){
            noticebox('提示','请上传商品图',1);
            return false;
        }
        //描述
        var describe =$('#myEditor').html();
        if(describe == ''){
           noticebox('提示','请填写详情描述',1);
            return false;
        }
        data = {};
        data['token']=token;
        data['id']=id;
        data['goods_name'] = goods_name;
        data['brand'] = brand;
        data['people_style'] = people_style;
        data['goods_style'] = goods_style;
        data['artnu'] = artnu;
        data['prodprovince_address'] = prodprovince_address;
        data['shipprovince_address'] = shipprovince_address;
        data['prodaddress'] = prodaddress;
        data['shipaddress'] = shipaddress;
        data['attr'] = attr;
        data['price_attr'] = price_attr;
        data['price_attr_value'] = price_attr_value;
        data['notice_nu'] = notice_nu;
        data['freightmodel'] = freightmodel;
        data['weight'] = weight;
        data['image'] = image;
        data['describe'] = describe;

        $.ajax({
            type:"post",
            url:"http://ww.yc630.com/api/index.php/Seller/Goods/goods_update",
            data:data,
            dataType:'json',
            success:function(phpdata){
                noticebox('提示','商品保存成功',1,'goods_house.html');
            }
        });

    })

    $('#fabu').click(function(){
        $('.save_back').click();
    })
    $('#cancel').click(function(){
        noticebox('提示','您编辑的信息将无法保存，确定要不发布离开吗？',2,'goods_house.html');
    })
})
function brandfu(optionID){
    var all_options = document.getElementById('brand').options;
    for (i=1; i<all_options.length; i++){
        if (all_options[i].innerHTML == optionID)  // 根据option标签的ID来进行判断  测试的代码这里是两个等号
        {
            all_options[i].selected = true;
        }
    }
};
function ps(optionID){
    var all_options = document.getElementById('people_style').options;
    for (i=1; i<all_options.length; i++){
        if (all_options[i].innerHTML == optionID)  // 根据option标签的ID来进行判断  测试的代码这里是两个等号
        {
            all_options[i].selected = true;
        }
    }
};
function gs(optionID){
    var all_options = document.getElementById('goods_style').options;
    for (i=1; i<all_options.length; i++){
        if (all_options[i].innerHTML == optionID)  // 根据option标签的ID来进行判断  测试的代码这里是两个等号
        {
            all_options[i].selected = true;
        }
    }
};
function sp(optionID){
    var all_options = document.getElementById('shipaddress_province').options;
    for (i=1; i<all_options.length; i++){
        if (all_options[i].innerHTML == optionID)  // 根据option标签的ID来进行判断  测试的代码这里是两个等号
        {
            all_options[i].selected = true;
        }
    }
};
function pp(optionID){
    var all_options = document.getElementById('prodaddress_province').options;
    for (i=1; i<all_options.length; i++){
        if (all_options[i].innerHTML == optionID)  // 根据option标签的ID来进行判断  测试的代码这里是两个等号
        {
            all_options[i].selected = true;
        }
    }
};
function fn(optionID){
    var all_options = document.getElementById('freight_name').options;
    for (i=1; i<all_options.length; i++){
        if (all_options[i].innerHTML == optionID)  // 根据option标签的ID来进行判断  测试的代码这里是两个等号
        {
            all_options[i].selected = true;
        }
    }
};
$(function(){
//    接收id
    var url=window.location.href
    var ids=url.split("?")[1]
    var id=ids.substring(3)
//    展示所有商品数据
    $.ajax({
        type:"post",
        url:"http://ww.yc630.com/api/index.php/Buyer/Goods/goodsDetail",
        data:{
            "goods_id":id,
            'token':token
        },
        dataType:"json",
        success:function(phpdata){
            var goods_name=phpdata['data']['goodmsg']['goods_name']
            var brand=phpdata['data']['goodmsg']['brand_name']
            var people_style=phpdata['data']['goodmsg']['people_style_name']
            var goods_style=phpdata['data']['goodmsg']['goods_style_name']
            var goods_style_id=phpdata['data']['goodmsg']['goods_style']
            var goods_list_num=phpdata['data']['goodmsg']['artnu']
            var shipaddress_province=phpdata['data']['goodmsg']['shipprovince_address_name']
            var shipaddress_city=phpdata['data']['goodmsg']['shipaddress_name']
            var shipaddress_city_id=phpdata['data']['goodmsg']['shipaddress']
            var prodaddress_province=phpdata['data']['goodmsg']['prodprovince_address_name']
            var prodaddress_name=phpdata['data']['goodmsg']['prodaddress_name']
            var prodaddress_name_id=phpdata['data']['goodmsg']['prodaddress']
            var weight=phpdata['data']['goodmsg']['weight']
            var notice_nu_num=phpdata['data']['goodmsg']['notice_nu']
            var freight_name=phpdata['data']['goodmsg']['freightmodel_name']
            var myEditor=phpdata['data']['goodmsg']['describe']
            var image=phpdata['data']['goodmsg']['image']
            var aa=image.split(',')
            var imageid=phpdata['data']['goodmsg']['image_id']
            var bb=imageid.split(',')
            var str=""
            for(var i=0;i<aa.length;i++){
                str += '<div style="position: relative" class="add_pic_btn imgs"><img class="little_sc" img_id="'+bb[i]+'" src="'+aa[i]+'"/><span class="little_sc" onclick="sc(this)">X</span></div>';
            }
            //按价格设定显示
            var priceattr=phpdata['data']['priceattr']
            var price_attr=""
            var attr=""
            for(i in priceattr){
                if(i!='统一定价'){
                    attr +='<tr><td class="z_td_w" name="'+i+'" style="text-align: left;width: 60px;">'+i+':</td><td>';
                    for(x in priceattr[i]){
                        if(x!=""){
                            attr +='<input class="z_s z_attrs" z_shu="'+i+'" z_names="'+x+'" type="checkbox" checked="checked" name=""  /> <label class="z_label">'+x+'</label> ' ;
                            pstr +='<tr class="z_list_main"><td><input value='+priceattr[i][x]['bar_code']+' style="height: 100%;border: 0;" type="text"  name="" id="" /></td><td>'+x+'</td><td><input value='+priceattr[i][x]['sell_price']+' style="height: 100%;border: 0;" type="text" name="" id="" /></td><td><input value='+priceattr[i][x]['price']+' style="height: 100%;border: 0;" type="text" name="" id="" /></td><td><input value='+priceattr[i][x]['stocks']+'  style="height: 100%;border: 0;" type="text" name="" id="" /></td></tr>';
                        }
                }
                    attr +='<a href="###" attr_name='+i+' class="hand_add hand_a">添加</a></td></tr>';
                }
                var pstr = '<tr class="z_head"><td style="width: 100px">条形码</td><td style="width: 100px!important;">'+i+'</td><td>销售价</td><td>原价</td><td>库存</td></tr>';
                for(x in priceattr[i]){
                    if(x!=""){
                        pstr +='<tr class="z_list_main"><td><input value='+priceattr[i][x]['bar_code']+' style="height: 100%;border: 0;" type="text"  name="" id="" /></td><td>'+x+'</td><td><input value='+priceattr[i][x]['sell_price']+' style="height: 100%;border: 0;" type="text" name="" id="" /></td><td><input value='+priceattr[i][x]['price']+' style="height: 100%;border: 0;" type="text" name="" id="" /></td><td><input value='+priceattr[i][x]['stocks']+'  style="height: 100%;border: 0;" type="text" name="" id="" /></td></tr>';
                    }
                }
                price_attr += '<input class="z_s" type="radio" checked="checked" name="price_attr" id="'+i+'" /><label class="z_label" for="'+i+'">按'+i+'设定</label>';
            }
            //按普通显示
            var nomalattr=phpdata['data']['nomalattr']
            var nomal_attr=""
            for(i in nomalattr){
                nomal_attr +='<tr><td class="z_td_w" name="'+i+'" style="text-align: left;width: 60px;">'+i+':</td><td>';
                for(x in nomalattr[i]){
                    if(nomalattr[i][x]!=""){
                        console.log(nomalattr[i][x])
                        nomal_attr +='<input class="z_s z_attrs" z_shu="'+i+'" z_names="'+nomalattr[i][x]+'" type="checkbox" checked="checked" name=""  /> <label class="z_label">'+nomalattr[i][x]+'</label> ' ;
                    }
                }
                nomal_attr +='<a href="###" attr_name='+i+' class="hand_add hand_a">添加</a></td></tr>';
                price_attr += '<input class="z_s" type="radio" name="price_attr" id="'+i+'" /><label class="z_label" for="'+i+'">按'+i+'设定</label>';
            }
            $('.price_attr').html(price_attr);
            $('.attr_table').append(attr);
            $('.attr_table').append(nomal_attr);
            $('.attr_list').html(pstr);
            $('.goods_img').prepend(str);
            $("#goods_name").val(goods_name)
            brandfu(brand)
            ps(people_style)
            var gs_html='<option value="'+goods_style_id+'">'+goods_style+'</option>';
            $('select[name="goods_style"]').html(gs_html);
            $("#goods_list_num").val(goods_list_num)
            sp(shipaddress_province)
            var sc_html='<option value="'+shipaddress_city_id+'">'+shipaddress_city+'</option>'
            $('select[name="shipaddress_city"]').html(sc_html)
            pp(prodaddress_province)
            var pn_html='<option value="'+prodaddress_name_id+'">'+prodaddress_name+'</option>'
            $('select[name="prodaddress_city"]').html(pn_html)
            $("#weight").val(weight)
            $("#notice_nu_num").val(notice_nu_num)
            fn(freight_name)
            $('#myEditor').html(html_decode(myEditor))
        }
    })
})
function sc(obj){
    $(obj).parent().remove()
}